/*          FILE: syntax.h
 *      Language: C
 *        Author: <Qiwei Feng> <Pufan He> <Yichao Zhou>
 *       Created: 2012-02-26 21:59:40
 * Last Modified: 2012-03-01 21:22:18
 *   Description:
 *       License: GNU GPL v3
 */

#ifndef __C_H_SYNTAX
#define __C_H_SYNTAX

#include "operator.h"


// Tree definition

typedef enum {
        EXPRESSION_NODE_OPERATOR = 0,
        EXPRESSION_NODE_VARIABLE,
        EXPRESSION_NODE_CONST
} expression_node_type_e;

typedef struct {
        expression_node_type_e expression_node_type;
} expression_node_t;

typedef struct {
        expression_node_t father;
        binary_operator_type_e binary_operator_type;
        expression_node_t *left_child;
        expression_node_t *right_child;
} expression_node_operator_t;

typedef struct {
        expression_node_t father;
        symbol_entry_t *entry; 
} expression_node_variable_t;

typedef struct {
        expression_node_t father;
        int value;
} expression_node_const_t;



// Statement definition

typedef enum {
        STATEMENT_ASSIGNMENT = 0,
        STATEMENT_READ,
        STATEMENT_WRITE
} statement_type_e;

typedef struct {
        statement_type_e statement_type;
} statement_t;

typedef struct {
        statement_t father;
        symbol_entry_t *lhs;
        expression_node_t *expr;
} statement_assignment_t;

typedef struct {
        statement_t father;
        symbol_entry_t *entry;
} statement_read_t;

typedef struct {
        statement_t father;
        expression_node_t *expr;
} statement_write_t;

statement_t *syntax_process(token_t *source_token);

#endif

/* vim: set syn=c ts=8 sts=8 sw=8 tw=79 ff=unix et : */
